﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI
{
    public class ServiceResult : Result
    {
        /// <summary>
        /// 构建一个没有错误的结果
        /// </summary>
        public ServiceResult()
        {
            IsSuccess = true;
            ErrorCode = CPPEI.ErrorCodes.NoError;
            Message = CPPEI.ErrorCodes.GetMessage(ErrorCode);
        }

        /// <summary>
        /// 构建有错误的结果，错误码需要在CPPEI.ErrorCodes里定义
        /// </summary>
        /// <param name="errorCode">错误码</param>
        public ServiceResult(int errorCode)
        {
            IsSuccess = false;
            ErrorCode = errorCode;
            Message = CPPEI.ErrorCodes.GetMessage(ErrorCode); ;
        }

        /// <summary>
        /// 构建有错误的结果
        /// </summary>
        /// <param name="errorCode"></param>
        /// <param name="message"></param>
        public ServiceResult(int errorCode, string message)
        {
            IsSuccess = false;
            ErrorCode = errorCode;
            Message = message;
        }
    }
}
